package com.stagegateway.gateway.config;

import cn.dev33.satoken.stp.StpInterface;
import com.stagegateway.gateway.service.RoleMenusService;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @description：TODO
 * @author： SAYE
 * @create： 2024/3/26 9:48
 */
public class StpInterfaceDefaultImpl implements StpInterface {

    @Resource
    private RoleMenusService roleMenusService;

    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return roleMenusService.getMenuCodeListByRoleId((Integer) redisTemplate.opsForValue().get(loginId+"-roleId"));
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        return roleMenusService.getMenuCodeListByRoleId((Integer) redisTemplate.opsForValue().get(loginId+"-userId"));
    }
}

